<template>
  <div class="common-page page-stats" v-loading.fullscreen="loading"></div>
</template>

<script>
import mixin from "../mixin";
import { string, int } from "../util";
export default {
  name: "page-stats",
  title: "惠企大数据",
  nodes: ["/menu/stats"],
  //childs: ["stats-order-city", "stats-order-team", "stats-order-government", "stats-order-government-city", "stats-attendance-team", "stats-evaluation-team", "stats-evaluation-government", "stats-evaluation-government-city", "stats-order-tag", "stats-article-policy", "stats-data-export"],
  childs: [
    "stats-order-city",
    "stats-order-government",
    "stats-order-government-city",
    "stats-evaluation-government",
    "stats-evaluation-government-city",
    "stats-order-tag",
    "stats-article-policy",
    "stats-data-export",
    "stats-article-sjwt",
    "stats-article-qqdy",
    "stats-article-gzzb",
    "stats-article-qjhb",
    "stats-article-goupranking",
  ], //"stats-article-fwxz"
  mixins: [mixin],
  data: () => ({
    loading: false,
  }),
  methods: {
    destroy() {
      if (this.loading) return;
      return true;
    },
    init() {
      if (this.loading) return;
      this.loading = true;
      this.$root.$refs.navbar.init();
      this.plugins.user
        .call(
          async () => {
            let res = await this.plugins.user.init();
            if (res.code === 0) {
            }
            return res;
          },
          async () => {
            if (this.access(this.$route.name)) return { code: 0 };
            return this.env.xhrErrors.find((error) => error.code === 4);
          }
        )
        .then((res) => {
          this.loading = false;
          this.$root.$refs.navbar.init();
          if (res.code === 0) {
            let name = this.$options.childs.find((name) => this.access(name));
            if (name) this.$router.replace(name);
          } else if (res.code === 2) {
            this.$root.$refs.navbar.login();
          } else {
            this.plugins.modal
              .alert("页面加载失败", res.code + "：" + res.msg, "error")
              .then(() => this.$router.replace("/home"));
          }
        });
    },
  },
};
</script>

<style lang="scss">
.page-stats {
  overflow: hidden;

  .box {
    margin: 100px;
    padding: 50px;
    background-color: #f6f6f6;

    .pop-box {
      position: absolute;
      left: 0;
      bottom: 0;
      width: 100%;
      height: 0;

      .text {
        font-size: 20px;
      }
    }
  }
}
</style>
